# -*- encoding:utf-8 -*-
"""
@作者：ven
@文件名：login.py
@时间：2022-11-07  16:37
@文档说明:
"""
from common.baseApi import BaseAPI
from utils.encrypteUtil import Encrypt


def status_code(response, *args, **kwargs):
    print(f"hook status doce: {response.status_code}")


class Login(BaseAPI):

    def login(self, data, getToken=True):

        data['password'] = Encrypt.encryptRSA(data['password'])
        res = super().request_send(json=data,hooks={"response": status_code})
        if getToken:
            return res.json()['data']['token']['accessToken']
        else:
            return res


if __name__ == '__main__':
    payload = {'username': 'root', 'password': 'admin', "authType": "PC", }
    res = Login().login(payload, getToken=True)
    print(res)
